/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "cargoxempleado")
@NamedQueries({@NamedQuery(name = "Cargoxempleado.findAll", query = "SELECT c FROM Cargoxempleado c"), @NamedQuery(name = "Cargoxempleado.findByIdcargoxempleado", query = "SELECT c FROM Cargoxempleado c WHERE c.idcargoxempleado = :idcargoxempleado")})
public class Cargoxempleado implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "idcargoxempleado")
    private Integer idcargoxempleado;
    @JoinColumn(name = "idCargo", referencedColumnName = "idCargo")
    @ManyToOne(optional = false)
    private Cargo idCargo;
    @JoinColumn(name = "legajo", referencedColumnName = "legajo")
    @ManyToOne(optional = false)
    private Empleado legajo;

    public Cargoxempleado() {
    }

    public Cargoxempleado(Integer idcargoxempleado) {
        this.idcargoxempleado = idcargoxempleado;
    }

    public Integer getIdcargoxempleado() {
        return idcargoxempleado;
    }

    public void setIdcargoxempleado(Integer idcargoxempleado) {
        Integer oldIdcargoxempleado = this.idcargoxempleado;
        this.idcargoxempleado = idcargoxempleado;
        changeSupport.firePropertyChange("idcargoxempleado", oldIdcargoxempleado, idcargoxempleado);
    }

    public Cargo getIdCargo() {
        return idCargo;
    }

    public void setIdCargo(Cargo idCargo) {
        Cargo oldIdCargo = this.idCargo;
        this.idCargo = idCargo;
        changeSupport.firePropertyChange("idCargo", oldIdCargo, idCargo);
    }

    public Empleado getLegajo() {
        return legajo;
    }

    public void setLegajo(Empleado legajo) {
        Empleado oldLegajo = this.legajo;
        this.legajo = legajo;
        changeSupport.firePropertyChange("legajo", oldLegajo, legajo);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcargoxempleado != null ? idcargoxempleado.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cargoxempleado)) {
            return false;
        }
        Cargoxempleado other = (Cargoxempleado) object;
        if ((this.idcargoxempleado == null && other.idcargoxempleado != null) || (this.idcargoxempleado != null && !this.idcargoxempleado.equals(other.idcargoxempleado))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "javaapplication2.Cargoxempleado[idcargoxempleado=" + idcargoxempleado + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
